-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote function planning #14718
Remote function planning #14718
Conversation
f21530d
to
cd20f3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Add rule to rewrite filter with remote function to project" LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the 1st and the 2nd commit.
...n/java/com/facebook/presto/functionNamespace/AbstractSqlInvokedFunctionNamespaceManager.java
Show resolved
Hide resolved
.../src/test/java/com/facebook/presto/sql/planner/iterative/rule/TestPlanRemoteProjections.java
Outdated
Show resolved
Hide resolved
public TestPlanRemoteProjections() | ||
{ | ||
FunctionManager functionManager = METADATA.getFunctionManager(); | ||
functionManager.addTestFunctionNamespace("unittest", new InMemoryFunctionNamespaceManager("unittest", new SqlInvokedFunctionNamespaceManagerConfig().setSupportedFunctionLanguages("sql,java"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use H2 FNM, which is designed for testing purpose. We can then avoid adding test-related method addTestFunctionNamespace
in our production code.
You can do that by first adding the factory:
static {
METADATA.getFunctionManager().addFunctionNamespaceFactory(new H2FunctionNamespaceManagerFactory());
}
You'll then be able to add a function namespace by
functionManager.loadFunctionNamespaceManager(
H2FunctionNamespaceManagerFactory.NAME,
"unittest",
ImmutableMap.of(<config key>, <config value>))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember I tried that but it didn't work. But I don't remember what didn't work. This is the problem of delayed review... Let me try again I guess...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason to not use H2FunctionNamespaceManagerFactory
is dependencies. This test is in presto-main. H2FunctionNamespaceManagerFactory
is in presto-tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3rd commit.
{ | ||
List<FunctionCall> externalFunctions = extractExternalFunctions(functionHandles, ImmutableList.of(predicate), functionManager); | ||
if (!externalFunctions.isEmpty()) { | ||
throw new SemanticException(NOT_SUPPORTED, predicate, "External functions in %s is not supported: %s", clause, externalFunctions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, for better readability of the constructed error message:
External functions in [%s] is not supported: %s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no unit test coverage for this commit. Can we add some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, for better readability of the constructed error message:
External functions in [%s] is not supported: %s
I don't think the [] is useful. It would make the error message like this:
External functions in [Lambda expression] is not supported:....
presto-main/src/main/java/com/facebook/presto/sql/analyzer/ExpressionTreeUtils.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/analyzer/ExpressionTreeUtils.java
Outdated
Show resolved
Hide resolved
cd20f3b
to
cd2775c
Compare
ef66bcd
to
7b3e57c
Compare
7b3e57c
to
5a488ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Add Locality to ProjectNode" LGTM
presto-main/src/main/java/com/facebook/presto/sql/planner/sanity/VerifyProjectionLocality.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Explicitly not supporting external functions in lambda and join filter" LGTM
Overall, looks good. It would be good to add a few tests that actually show a real plan string (like explain output) with external functions so the logic becomes clearer and will help future iterations on this feature. |
5a488ba
to
f06cf7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
presto-main/src/main/java/com/facebook/presto/metadata/FunctionManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chatted offline about testing the plans - will wait for the execution PR.
LGTM
We check the filter predicate in JOIN in PlanSanityChecker so we can cover correlated IN and lateral join that are converted to JOIN with filter predicate.
f06cf7b
to
b460e10
Compare
This PR introduced the concept of "remote function" into planner and generates query plan that's aware of the remote functions. Depends on #14219. Partially addresses #14053.
Ran verifier explain tests across all dcs and all tests passed.